﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Streaming_Services_WPF_Consumer
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {

        protected DfsWrapper m_dfsObj = null;
        protected String m_ObjectType = null;
        protected String m_r_object_id = null;

        public Window1()
        {
            InitializeComponent();
        }

        private void m_ScxButton_Click(object sender, RoutedEventArgs e)
        {
            String username = m_UsernameBox.Text;
            String password = m_PasswordBox.Password;
            String repository = m_RepositoryBox.Text;

            m_dfsObj = new DfsWrapper(repository, username, password);

            if (null != m_dfsObj)
            {
                m_ScxLabel.Content = "Service context header created.";
            }

        }

        private void m_ObjectIdButton_Click(object sender, RoutedEventArgs e)
        {
            m_ObjectType = m_ObjectTypeBox.Text;
            String objectName = m_ObjectNameBox.Text;

            String dqlStr = "select r_object_id from " + m_ObjectType + " WHERE object_name = '" + objectName + "'";
            String objectId = null;

            m_dfsObj.DQL_To_Execute = DfsWrapper.QueryType.Get_R_Object_ID;
            m_dfsObj.executeDQL(dqlStr);
            objectId = m_dfsObj.Object_ID;

            m_ObjectIdLabel.Content = objectId;
            m_r_object_id = objectId;

        }

        private void m_MmsUrlButton_Click(object sender, RoutedEventArgs e)
        {
            String dqlStr = "select mfile_url('wmv', -1, '') from " + m_ObjectType + " WHERE r_object_id = '" + m_r_object_id + "'";
            String mmsUrl = null;

            m_dfsObj.DQL_To_Execute = DfsWrapper.QueryType.Get_MMS_URL;
            m_dfsObj.executeDQL(dqlStr);
            mmsUrl = m_dfsObj.WMS_URL;
            m_MmsUrlLabel.Content = mmsUrl;
        }


    }
}
